package com.ctyun.xstore.vod.transcode;

import java.io.IOException;

import com.ctyun.xstore.vod.AbstractVODClient;
import com.ctyun.xstore.vod.transcode.model.CancelTranscodeTaskRequest;
import com.ctyun.xstore.vod.transcode.model.CancelTranscodeTaskResponse;
import com.ctyun.xstore.vod.transcode.model.CreateExtractFrameRequest;
import com.ctyun.xstore.vod.transcode.model.CreateExtractFrameResponse;
import com.ctyun.xstore.vod.transcode.model.CreateTranscodeTaskRequest;
import com.ctyun.xstore.vod.transcode.model.CreateTranscodeTaskResponse;
import com.ctyun.xstore.vod.transcode.model.QueryTaskProcessRequest;
import com.ctyun.xstore.vod.transcode.model.QueryTaskProcessResponse;
import com.ctyun.xstore.vod.transcode.model.RetryTranscodeTaskRequest;
import com.ctyun.xstore.vod.transcode.model.RetryTranscodeTaskResponse;
import com.ctyun.xstore.vod.transcode.model.RetryWorkFlowTranscodeTaskRequest;
import com.ctyun.xstore.vod.transcode.model.SearchTranscodeTaskRequest;
import com.ctyun.xstore.vod.transcode.model.SearchTranscodeTaskResponse;

public class TranscodeTaskClient extends AbstractVODClient {

	public TranscodeTaskClient(String accessKey, String secretKey) {
		super(accessKey, secretKey);
	}

	public TranscodeTaskClient(String host, String accessKey, String secretKey) {
		super(host, accessKey, secretKey);
	}

	/**
	 * 创建截帧任务
	 *
	 * @param request 创建截帧任务请求的参数,详见CreateExtractFrameRequest
	 * @return 创建截帧任务的结果，详见CreateExtractFrameResponse
	 * @throws IOException 可能会发生 IO 异常。
	 */
	public CreateExtractFrameResponse createExtractFrame(CreateExtractFrameRequest request) throws IOException {
		return this.execute(request, CreateExtractFrameResponse.class);
	}

	/**
	 * 创建/批量创建转码任务
	 *
	 * @param request 创建转码任务请求的参数，详见CreateTranscodeTaskRequest
	 * @return 创建转码任务的结果，详见CreateTranscodeTaskResponse
	 * @throws IOException 可能会发生 IO 异常。
	 */
	public CreateTranscodeTaskResponse createTranscodeTask(CreateTranscodeTaskRequest request) throws IOException {
		return this.execute(request, CreateTranscodeTaskResponse.class);
	}

	/**
	 * 重试点播模式转码任务
	 */
	public RetryTranscodeTaskResponse retryTranscodeTask(RetryTranscodeTaskRequest request) throws IOException {
		return this.execute(request, RetryTranscodeTaskResponse.class);
	}

	/**
	 * 重试托管模式转码任务
	 */
	public RetryTranscodeTaskResponse retryWorkFlowTranscodeTask(RetryWorkFlowTranscodeTaskRequest request)
			throws IOException {
		return this.execute(request, RetryTranscodeTaskResponse.class);
	}

	/**
	 * 查询转码任务状态
	 *
	 * @param request 查询转码任务状态请求的参数，QueryTaskProcessRequest
	 * @return 创建转码任务的结果，QueryTaskProcessResponse
	 * @throws IOException 可能会发生 IO 异常。
	 */
	public QueryTaskProcessResponse queryTaskProcess(QueryTaskProcessRequest request) throws IOException {
		return this.execute(request, QueryTaskProcessResponse.class);
	}

	/**
	 * 搜索转码任务
	 *
	 * @param request 查询转码任务状态请求的参数，SearchTranscodeTaskRequest
	 * @return 创建转码任务的结果，SearchTranscodeTaskResponse
	 * @throws IOException 可能会发生 IO 异常。
	 */
	public SearchTranscodeTaskResponse searchTranscodeTask(SearchTranscodeTaskRequest request) throws IOException {
		return this.execute(request, SearchTranscodeTaskResponse.class);
	}

	/**
	 * 取消指定taskId转码任务
	 * 
	 * @param request
	 * @return
	 * @throws IOException
	 */
	public CancelTranscodeTaskResponse cancelTranscodeTask(CancelTranscodeTaskRequest request) throws IOException {
		return this.execute(request, CancelTranscodeTaskResponse.class);
	}
}
